<?php
/**
 * Created by PhpStorm.
 * User: bobo
 * Date: 17-12-26
 * Time: 上午12:06
 */

namespace WsdServer\Lib\Validation;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Translation\FileLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Factory;

/**
 * 验证器类(请参考laravel)
 * Class Validator
 */
class Validator extends Factory
{
    /***
     * 创建实例
     * @return Factory
     */

    public static function getInstance()
    {
        static $validator = null;
        if ($validator === null) {
            $translation_path = __DIR__.'/laravel-lang/src';
            $translation_locale = 'zh-CN';
            $translation_file_loader = new FileLoader(new Filesystem, $translation_path);
            $translator = new Translator($translation_file_loader, $translation_locale);
            $validator = new Factory($translator);
        }
        return $validator;

    }

}
